import os
from http.server import HTTPServer,CGIHTTPRequestHandler
if __name__ == '__main__':
    webdir = '.'  # 设置网站的根目录为程序所在路径
    port = 8000  # 设置一个端口
    os.chdir(webdir)
    server_address = ('', port)  # 设置服务器地址
    server_obj = HTTPServer(server_address, CGIHTTPRequestHandler)  # 创建服务器对象
    print('server runing.....')
    print('prot is ', port)
    server_obj.serve_forever()  # 启动服务器